<div class="member-main member-main2" id="J_DataTable">
    <input type="hidden" class="suppliers">
	<div class="member_welhead"><ins></ins><b><{t}>新订单 новый заказ<{/t}></b> </div>
	<div class="page-article" id="main">
		<div id="member_notify" class="member-notify">
			<{if $goods}>
			<form id="no-inventory-form" action="<{link app=b2c ctl=site_member act=to_confirm full=1}>" method="post">

				<div style="text-align:right"  class="confirm-batch">
					<!--<button class="trigger-btn" rel="_request" style="background-color:gray;border:0;color:white;"><{t}>批量确认已选商品<{/t}></button>-->
					<input type="button" class="operations btn btn-default" value="<{t}>批量确认库存 Утвердить выделенные остатки<{/t}>"  onclick="javascript:(0);">
				</div>

				<input type="hidden" id="obj_id" name="obj_id" value="">
				<input type="hidden" id="opt" name="opt" value="all">
				<input type="hidden" id="pro" name="pro" value="">

				<div class="member-mod table-responsive">
					<table class="member-grid table table-hover table-bordered table-striped">
						<thead>
						<tr>
							<th><input type="checkbox" class="all-selector"  name="controllAll" id="controllAll" onclick="selectAll()"></th>
                            <th><{t}>订单 Заказ<{/t}></th>
							<th><{t}>商品 Товар<{/t}></th>
							<th><{t}>数量 Количество<{/t}></th>
                            <th><{t}> 结算单价（每双）Цена расчета/пара<{/t}></th>
							<th><{t}>确认库存 Подтверждение остатка<{/t}></th>
							<!--	<th><{t}>数量<{/t}></th>
                                <th><{t}>操作<{/t}></th>-->
						</tr>
						</thead>
						<tbody>
						<{foreach from=$goods item=items}>
						<tr ggid="<{$items.goods_id}>" class="ggid" rg_id="">
							<td><input class="ck-grey" type="checkbox" name="is_checked[]" value="<{$items.obj_id}>"></td>
                            <td>
                                销售订单号 Номер заказа: <br/><{$items.mainOrder_id}><br/>
                                下单时间 Время заказа: <br/><{$items.createtime|cdate}>
                            </td>
							<td>

								<div class="p-pic fl">
									<img alt="<{$items.name}>" src="<{$items.image_default_id}>">
								</div>
								<div class="fl">
									<!--商品名称-->
									<{$items.name}><br/>
									<!--品牌-->
									品牌 Бренд: <{$items.goods.brand.brand_name}><br/>
									<!--货品编码-->
									货品编码 Артикул: <{$items.bn}><br/>
                                    季节 Сезон:  <{$items.season}><br/>
									<!-- 价格-->
									价格 Цена за короб.:  <{$items.price|cur_odr}><br/>
                                    <div class="size_all suppliers_table">
                                        <table class="table table-hover table-striped table-condensed table-bordered">
                                            <{foreach from=$items.goods.params key=key item=item}>
                                            <thead>
                                            <tr class="small">
                                                <{foreach from=$item key=key2 item=item2}>
                                                <{if !empty($item2) && $item2 > 0 && $key2 != "Кол-во в упаковке" }>
                                                <th><{$key2}></th>
                                                <{/if}>
                                                <{/foreach}>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr class="small">
                                                <{foreach from=$item key=key2 item=item2}>
                                                <{if !empty($item2) && $item2 > 0 && $key2 != "Кол-во в упаковке" }>
                                                <td><{$item2}></td>
                                                <{/if}>
                                                <{/foreach}>
                                            </tr>
                                            </tbody>
                                            <{/foreach}>
                                        </table>
                                    </div>
								</div>
								<!-- <{$items.goods.image_default_id|storager:'s'}>-->

							</td>
							<!--  每包数量-->
							<!-- <td><{$items.goods.unit_num}></td>-->
							<!--确认数量-->
							<td><{$items.quantity}></td>
                            <td><{$items.goods.cost|cur_odr}></td>
							<td>
								<span class="quantity"><{input type="text" vtype="required&&number" value=$items.quantity name="confirm_num[{$items.obj_id}]" id="confirm-{$items.obj_id}" onblur="check(this,{$items.quantity},{$items.obj_id})"}></span>
								<button type="submit" class="single_confirm btn btn-sm btn-primary"  onclick="do_sbc_edit(this,'<{$items.obj_id}>','<{$items.product_id}>')" rel="_request"><{t}>确认<{/t}></button>
								<!--<a href="<{link app=b2c ctl='site_member' full='1' act='recommend' arg=$items.obj_id}>" class="recommend" rel="<{$items.goods.goods_id}>" rrid=""><{t}>推荐<{/t}></a>-->
								<input type="hidden" name="r_goods_id" value="" id="rnd"/>
							</td>
							<!--<td><{$items.quantity}></td>-->
						</tr>
						<!--	<tr ggid="<{$items.goods_id}>">
                                <td><{t}>确认数量：<{/t}></td>
                                <td><{$items.has_confirm_num}></td>
                                <td >

                                </td>
                                <td class="flg">
                                &lt;!&ndash;<a href="javascript:;" class="single_confirm" onclick="do_sbc_edit(this,'<{$items.obj_id}>')"><{t}>确认<{/t}></a>&ndash;&gt;
                            </td>
                            </tr>-->
						<{/foreach}>
						</tbody>
					</table>
				</div>

			</form>
			<{pagers data=$pager}>
			<{else}>
			<{t}>暂无商品<{/t}>
			<{/if}>
		</div>
	</div>
</div>
<script>
	(function(){
		var _form = $('no-inventory-form');
	})();

	//没有选择商品时，按钮为灰色
	$$('#no-inventory-form .ck-grey').addEvent('click',function(e){
		if(show().length == 0){
			no_checked();
		}else{
			has_checked();
		}
	});

	//选中商品的状态为黄色
	function has_checked(){
		ul = '<button type="submit" class="trigger-btn btn btn-primary" rel="_request" ><{t}>批量确认已选商品<{/t}></button>';
		$$('#no-inventory-form .confirm-batch').set('html',ul);
	}

	//不选中时为灰色
	function no_checked(){
		ul = '<input type="button" class="operations btn btn-default" value="<{t}>批量确认库存<{/t}>" onclick="javascript:(0);">';
		$$('#no-inventory-form .confirm-batch').set('html',ul);
	}

	//获取选中商品
	function show(){
		var cBox = document.getElementsByName("is_checked[]");
		var idents = new Array();
		for(i = 0;i < cBox.length;i++){
			if(cBox[i].checked){
				idents.push(cBox[i].checked);
			}
		}
		return idents;
	}

	function check(obj,quantity,obj_id){
		var gc_confirm_num = $$('#confirm-'+obj_id).get('value');

		if(isNaN(gc_confirm_num)){
			alert("<{t}>请输入非负整数!<{/t}>");
			$$('#confirm-'+obj_id).set('value',quantity);
			return;
		}
		var reg = /^[1-9]\d*|0$/;
		var re = new RegExp(reg);
		if (re.test(gc_confirm_num) == null) {
			alert("<{t}>请输入正确的数量!<{/t}>");
			$$('#confirm-'+obj_id).set('value',quantity);
			return;
		}

		if(gc_confirm_num < 0){
			alert("<{t}>请输入非负整数!<{/t}>");
			$$('#confirm-'+obj_id).set('value',quantity);
			return;
		}
		if(gc_confirm_num > quantity){
			alert("<{t}>请输入非负整数的数量!<{/t}>");
			$$('#confirm-'+obj_id).set('value',quantity);
			return;
		}
	}

	function do_sbc_edit(e,obj_id,pro){
		$('obj_id').set('value',obj_id);
		$('opt').set('value','single');
		$('pro').set('value',pro);
//    $('no-inventory-form').submit();
	}


	function selectAll(){
		var arr = document.getElementsByName("is_checked[]");
		var is_checked = arr[0].checked;
		for(var i = 0;i < arr.length;i++){
			if(is_checked){
				arr[i].checked = false;
			}else{
				arr[i].checked = true;
			}
		}
		if(is_checked){
			no_checked();
		}else{
			has_checked();
		}
	}


	//  ===============================列表页面图片变大效果=======================================================
	jQuery(".member-grid  tr td .p-pic").hover(function(){
		var owntop=jQuery(window).height()-(jQuery(this).offset().top - jQuery(document).scrollTop()+50);
		var new_img= jQuery(this).clone();
		jQuery(this).parent().append(new_img);
		jQuery(this).siblings('.p-pic').addClass('letbig').stop().animate({width:160, height:160,top:68,left:68},0);
	},function(){
		jQuery(this).siblings('.p-pic').remove();
	});

</script>